<?php
namespace Tyrone\Command;
use Tyrone\Model\Game\PayLog;
use Tyrone\Model\Game\Role;
use Swoole\Coroutine;
class RoleOnlineStatistics extends DayOnline
{

    protected $stat_project = 0;
    protected $day_online_type = 0;


    public  function execute()
    {
        var_dump('RoleOnlineStatistics');
        $channel = $this->channel;
        $class = get_class($this);
        $method = 'insertDayOnlineData';
        $date = date("Ymd", strtotime($this->sDate));
        $params = ['db',$date,'data',1];
        $data = [
           ['day'=>20250923,'plat_server'=>$this->plat_server,'stat_project'=>1,'type'=>$this->day_online_type],

        ];
        $channel->push(compact('class','method','params','data'),1);
        return $this->result(['test']);
        ini_set('memory_limit', '1G');
        $database = $this->database;
        $game_database = $this->game_mysql;
        $mysql = $this->mysql;
        $currentTimestamp = time();
        $date = date("Ymd", strtotime($this->sDate));

        $this->setFrequency(300);

        $roleModel = new Role($game_database);
        //当前在线数据
        $onlineInfo = $roleModel->getCurrentOnline(['is_online'=>1]);
        $loginData = $roleModel->getCurrentOnline([
            "last_login_time[<>]"=>[strtotime($this->sDate . " 00:00:00"), strtotime($this->eDate . " 23:59:59")],
        ]);
        $regData = $roleModel->getCurrentOnline([
            "reg_time[<>]"=>[strtotime($this->sDate . " 00:00:00"), strtotime($this->eDate . " 23:59:59")],
        ]);

        //插入
        $this->insertDayOnlineData($mysql,$date,$onlineInfo,1);
        $this->insertDayOnlineData($mysql,$date,$loginData,5);
        $this->insertDayOnlineData($mysql,$date,$regData,6);

        return $this->result([count($onlineInfo),count($loginData),count($regData)]);
    }

    public function insertDayOnlineData($mysql,$date,$datas,$stat_project){
        print_r(func_get_args());
        /*$DayOnline = new \Tyrone\Model\DayOnline($mysql);
        $day = date("Ymd", strtotime($date));
        foreach ($datas as $platform =>$item){
            $item += ['day'=>$day,'plat_server'=>$this->plat_server,'stat_project'=>$stat_project,'type'=>$this->day_online_type];
            $other = ['master_platform'=>$this->platform];
            $DayOnline->insertData($item,$this->minus,'num',$other);
        }*/
    }
}